﻿using Modles.DTO;
using Modles.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace BilbilDAL
{
    public class VideoTypeDAL
    {
        /// <summary>
        /// 获取视频类型
        /// </summary>
        /// <returns></returns>
        public List<VideoType_DTO> GetVideoType()
        {
            using (VideoPlatformDbContext con = new VideoPlatformDbContext())
            {
                IQueryable<VideoType_DTO> query = from videoType in con.VideoTypes
                                              select new VideoType_DTO
                                              {
                                                  Id = videoType.Id,
                                                  Type = videoType.Type
                                              };
                return query.ToList(); 
            }
        }
        /// <summary>
        /// 检查视频类型是否存在
        /// </summary>
        /// <param name="typeId"></param>
        /// <returns></returns>
        public bool IsVideoTypeExists(int typeId)
        {
            using (VideoPlatformDbContext con = new VideoPlatformDbContext())
            {
                return con.VideoTypes.Any(vt => vt.Id == typeId);
            }
        }
    }
}
